﻿using System;
using Chengqbd.Core.Common;

namespace Chengqbd.Core.Extensions
{
	public static class EncryptExtensions
	{
        /// <summary>
        /// 加密密码
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
		public static string HashPassword(this string value)
		{
			return PasswordHelper.HashPassword(value);
		}
        /// <summary>
        /// 检索密码
        /// </summary>
        /// <param name="hashedPassword"></param>
        /// <param name="providedPassword"></param>
        /// <returns></returns>
		public static bool VerifyHashedPassword(this string hashedPassword, string providedPassword)
		{
			return PasswordHelper.VerifyHashedPassword(hashedPassword, providedPassword);
		}
        /// <summary>
        /// MD5加密
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
		public static string MD5(this string value)
		{
			return EncryptProvider.Md5(value, MD5Length.L32);
		}
        /// <summary>
        /// AES加密
        /// </summary>
        /// <param name="value"></param>
        /// <param name="key"></param>
        /// <returns></returns>
		public static string AESEncrypt(this string value, string key)
		{
			return EncryptProvider.AESEncrypt(value, key);
		}
        /// <summary>
        /// AES解密
        /// </summary>
        /// <param name="value"></param>
        /// <param name="key"></param>
        /// <returns></returns>
		public static string AESDecrypt(this string value, string key)
		{
			return EncryptProvider.AESDecrypt(value, key);
		}
	}
}
